package com.ihisun.tmhcms.core.service.agreementservice.impl;

import com.ihisun.tmhcms.core.dao.agreementdao.AgreementDao;
import com.ihisun.tmhcms.core.dao.agreementdao.EditAgreementDao;
import com.ihisun.tmhcms.core.dto.agreementdto.AgreementDto;
import com.ihisun.tmhcms.core.service.agreementservice.AgreementService;
import com.ihisun.tmhcms.core.vo.AgreementVo;
import com.ihisun.tmhcms.utils.DateUtils;
import com.ihisun.tmhcms.utils.ResponseVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AgreementServiceImpl implements AgreementService {
    @Resource
    AgreementDao agreementDao;
    @Resource
    EditAgreementDao editAgreementDao;

    @Override
    public ResponseVo echoAgreement() {
        List<AgreementVo> all = agreementDao.findAll();
        return ResponseVo.ok(all);
    }

    @Override
    public ResponseVo editAgreement(AgreementDto agreementDto) {
        agreementDto.setCreateTime(DateUtils.getCurrentTime());
        agreementDto.setUpdateTime(DateUtils.getCurrentTime());
        editAgreementDao.save(agreementDto);
        return ResponseVo.ok();
    }
}
